class smx_selenium {
  require smx_os
  require smx_download
  Exec { path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/' ] }
  package { 'gtk3':
    ensure => installed,
  }

  package { 'alsa-lib.x86_64':
    ensure => installed,
  }

  $xorg_x11_packagelist = [
    'xorg-x11-server-Xvfb',
    'xorg-x11-fonts-Type1',
    'xorg-x11-font-utils',
  ]

  package { $xorg_x11_packagelist:
    ensure => installed,
  }

  file { '/etc/init.d/xvfbd' :
    ensure  => file,
    mode    => 755, owner => root, group => root,
    source  => 'puppet:///modules/smx_selenium/xvfbd',
    require => Package[$xorg_x11_packagelist],
  }

  file { '/etc/init.d/selenium' :
    ensure => file,
    mode   => 755, owner => root, group => root,
    source => 'puppet:///modules/smx_selenium/selenium',
  }

  #should install firefox when the version 46 is avaible in yum repo . can do it like follow
  #get the version info through yum --showduplicates list firefox | expand
  #package { 'firefox':
  #  ensure => 45.2.0-1.el7.centos,
  #}


  file { '/vagrant/vagrant/installfirefox.sh':
    ensure => present,
    mode   => '0755',
    #    owner => root, group => root,
    source =>  "puppet:///modules/smx_selenium/installfirefox.sh",
  }

  exec { 'installfirefox':
    cwd       => '/vagrant/vagrant',
    command   => "/vagrant/vagrant/installfirefox.sh ",
    require   => File['/vagrant/vagrant/installfirefox.sh'],
  }

  #  service { 'xvfbd':
  #    enable => false,
  #    ensure => stopped ,
  #    subscribe => File['/etc/init.d/xvfbd'],
  #  }

  # file { '/usr/local/bin/mysqlinit.sh':
  #    ensure => file,
  #    mode   => 755, group => root, owner => root,
  #   source => 'puppet:///modules/smx_selenium/mysqlinit.sh',
  # }

  #  exec { 'mysql-init':
  #     command => '/usr/local/bin/mysqlinit.sh',
  #    subscribe => File['/usr/local/bin/mysqlinit.sh'],
  #    refreshonly => true,
  # }

  # file { '/etc/init.d/selenium' :
  #   ensure => file,
  #   mode => 755, owner => root, group => root,
  #   source => 'puppet:///modules/smx_selenium/selenium',
  # }

  #  service { 'selenium':
  #   enable => true,
  #   ensure => running,
  #  subscribe => File['/etc/init.d/selenium'],
  # }
}
